<?php

class Application_Form_FormRegister extends Zend_Form
{

    public function init()
    {
        /* Form Elements & Other Definitions Here ... */
        $this->setName('useradd');
        $this->setMethod('POST');
//        $this->setAction('../User/add');
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel('用户名')
                ->setRequired(true)
                ->setAttrib('MaxLength', '32')
                ->setAttrib('class','border')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('密码')
                ->setRequired(true)
                ->setAttrib('class','border')
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('StringLength',false,array(6,20));
        $repassword = $this->createElement('password', 'repassword',array(
            'label' => '重复密码',
            'required' => true));
        $repassword->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->setAttrib('class','border')
                ->addValidator('StringLength',FALSE,array(6,20));
        $email = $this->createElement('text', 'email', array(
            'label' => '邮箱',
            'required' => true,
            'class'=>'border',
            'filters' => array('StripTags','StringTrim'),
            'validators' => array('EmailAddress')
        ));
        $gender = $this->createElement('select', 'gender');
        $gender->setLabel('性别')
                ->setRequired(true)
                ->setAttrib('class','border')
                ->addMultiOption('0','男')
                ->addMultiOption('1','女');
        $qq = $this->createElement('text', 'qq', array(
            'Label' => 'QQ',
            'required' => true,
            'class'=>'border',
            'filters' => array('StringTrim'),
            'validators' => array('NotEmpty','Digits')
        ));
        $msn = $this->createElement('text', 'msn',array(
            'label' => 'MSN',
            'required' => true,
            'filters' => array('StringTrim','StripTags'),
            'validators' => array('NotEmpty'),
            'class'=>'border'
        ));
       // $captcha = new Zend_Form_Element_Captcha('checkcode');
        $captcha = $this->createElement('captcha', 'captcha', array(
            'label'      => '请输入下面的文字',
            'required'   => true,
            'captcha'    => array(
                'captcha' => 'Dumb',
                'wordLen' => 5,
                'timeout' => 300
            )
        ));
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton')
                ->setAttrib('class','border')
                ->setAttrib('class', 'submit');
        $submit->setLabel('注册');
        
        $this->addElements(array($username,$password,$repassword,$email,$gender,$qq,$msn,$submit));
    }


}

